<?php
// $Id: results.tpl.php,v 1.5 2007/10/11 09:51:29 goba Exp $
global $base_url,$language;
  $url = $base_url . '/' . drupal_get_path('module', 'acts');
//print_r($language);
//print "<pre>";print_r($items); print"</pre>";
 
$go_year ='';
$curdept ='';
?>
<?php 
		$i=0;           
		 foreach($items as $nid){
		 	my_db_change(1);
		 	$vid = db_query('SELECT vid FROM {node} WHERE nid = :nid', array(':nid' => $nid))->fetchField();
		 	$row = node_load($nid, $vid);
		 	my_db_change(0);
			$deptname = $row->field_act_dpt['und'][0]['value'];
			$actyear = $row->field_act_year['und'][0]['value'];			 		 
		
if(empty($row->field_act_file_upload['und'][0]['uri'])) {	
	$icon ='';	
	$filepath = $row->field_act_url['und'][0]['value']; 
}
else { 
 	$icon ='<img alt="Download Icon" src="http://cms.tn.gov.in/sites/default/files/icons/pdf_icon.gif">';
    $link = $row->field_act_file_upload['und'][0]['uri'];		
			$wrapper = file_stream_wrapper_get_instance_by_uri($link);
	if($wrapper == true){
		 $filepath = $wrapper->getDirectoryPath() . "/" . file_uri_target($link);
	}
	$filepath="http://cms.tn.gov.in/tncms_latest/$filepath";
    if ($row->field_act_file_upload['und'][0]['filesize'] != '0') {
		$kb = ceil($row->field_act_file_upload['und'][0]['filesize']/1024);
		$kbyte= $kb.KB;
		if($kb >1024) { 
			$kb = ceil($kb/1024);
			$kbyte= $kb.MB;
		}
   }
}
?>
<div class='act_box'>
	<div class='acts_year_header_others'>
	 <?php $flag = 0;
 if($actyear != $go_year)
   { 
   if($flag == 0){
	$go_year = $actyear;
  } ?> 
	<strong>Year : <?php if( $actyear=='') { echo "----"; } else{ echo ucfirst( $actyear); }}?> </strong>
	</div>
	<div  class='act_abstract'>							   
		<p><a onclick="return tnportal_window('<?php print $filepath ?>');" href="javascript:void(0);" >
		<?php echo ucfirst($row->field_act_title['und'][0]['value']).$icon; ?><span>(<?php echo $kbyte; ?>)</span></a></p>
		<?php //echo $row->field_act_objectives['und'][0]['value']; ?>
	</div>
</div>
<?php $i++; } ?>
<?php if($i == '0'){?>
	 <div class="no_record">No Results Found </div>
<?php }	?>
